<template>
  <div class="container">
    <router-view />
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import {
  openItem,
  addFilesAndFoldersByPayload,
  addWebsiteByPayload,
} from "./views/home/js/record";
onMounted(() => {
  window.utools.onPluginEnter(({ code, type, payload, option }) => {
    // 隐藏主窗口
    utools.hideMainWindow();

    if (code === "file-collections") {
      // 从文件收藏首页进入,直接显示主窗口
      utools.showMainWindow();
    } else if (code === "match_files_dirs") {
      // 从文件匹配进入
      utools.showMainWindow();
      addFilesAndFoldersByPayload(payload);
    } else if (code === "match_url") {
      // 从文件匹配进入
      utools.showMainWindow();
      addWebsiteByPayload(payload);
    } else {
      // 从文件或文件夹快速打开入口进入
      // 打开文件或文件夹
      const [path, type] = code.split("|");
      openItem({ path, type });
      // 退出插件,否则再次换出utools时，文件收藏插件是打开的
      utools.outPlugin();
    }
  });
  window.utools.onPluginOut((isKill) => {
    console.log("isKill", isKill);
  });
});
</script>
